package org.javaexpert.spaces.masterworker;

import java.util.Date;

/**
 * Created by IntelliJ IDEA.
 * User: piotrga
 * Date: Dec 18, 2007
 * Time: 11:10:22 PM
 * To change this template use File | Settings | File Templates.
 */
public class TaskStatusData {
    public Long taskId;
    public Long groupId;
    public TaskStatus status;
    public Boolean finished;
    public Boolean consumed;
    public String workerId;
    public Date startTime;
    public Date finishTime;
    public String comment;
    public Integer retryCount;

    public boolean isFailed() {
        return status == TaskStatus.FAILED;
    }

    public boolean isBeingExecuted() {
        return status == TaskStatus.IN_PROGRESS
                || status == TaskStatus.RESTARTING;
    }

    public enum TaskStatus {
        PENDING, IN_PROGRESS, SUCCEDED,
        AWAITING_RESTART, RESTARTING, FAILED,
        STOPPING, CANCELLED
    }


    public String toString() {
        return "TaskStatusData{" +
                "taskId=" + taskId +
                ", status=" + status +
                ", finished=" + finished +
                ", consumed=" + consumed +
                ", workerId='" + workerId + '\'' +
                ", startTime=" + startTime +
                ", finishTime=" + finishTime +
                ", comment='" + comment + '\'' +
                ", retryCount=" + retryCount +
                '}';
    }
}
